<?php
/* * 注意此文档为UTF-8的编码.
 * Created on 2010-6-29
 *
 * @author EXT <isrn@qq.com>
 *
 */
include ('../../includes/global.php');
include ('../global.php');
include ("../power.php");
switch ($_REQUEST['op']) {
    case 'rtp': {
            $dbinfo = Dgd(array(
                'db' => 'd_sevenel',
                'tn' => "rtp",
                'cd' => " del != '1' "
                    ));
            foreach ($dbinfo as $db) {
                $nodes[] = array('id' => $db['id'], 'tt' => $db['tt']);
            }

            echo json_encode($nodes);
            break;
        }
    case 'sort': {
            $dbinfo = Dgd(array(
                'db' => 'd_sevenel',
                'tn' => 'sort',
                'cd' => " parentid = '" . $_GET['id'] . "' and del = 0 ",
                    ));
            foreach ($dbinfo as $db) {
                $nodes[] = array('id' => $db['id'], 'title' => $db['title']);
            }
            echo json_encode($nodes);
            break;
        }
    case 'kong': {
            $nodes[] = '';
            echo json_encode($nodes);
            break;
        }
    default: {
            $cfg = Dgd(array(
                'db' => 'd_sevenel',
                'cd' => " id = " . $_REQUEST['id'],
                'tn' => "fld",
                'limit' => 1
                    ));
            $config = json_decode($cfg['cfg'], true);

            /**
             * 自定义搜索条件
             */
            if($_POST['custom'] != ''){
                foreach($_POST['custom'] as $k => $v){
                    $custom_config .= " and {$k}='{$v}'";
                }
            }

            $dbinfo = Dgd(array(
                'db' => 'd_sevenel',
                'tn' => $config['table'],
                'cd' => "del!=1 {$custom_config} and ".$config['conditon'] . "  ",
                    ));
            //$nodes[] = array($config['y']=>'', $config['x']=>'请选择');
            $nodes = array();
            foreach ($dbinfo as $db) {
                $nodes[] = array($config['y'] => $db[$config['y']], $config['x'] => $db[$config['x']]);
            }
            echo json_encode($nodes);
            break;
        }
}
?>
